package com.liu.demo.service;

import com.liu.demo.pojo.Teacher;
import com.liu.demo.prository.TeacherPrository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class TeacherService {

    @Autowired
    private TeacherPrository teacherPrository;

    //查找所有信息
    public List<Teacher> findAll(){
        return teacherPrository.findAll();
    }

   // 按学工号查找
    public Teacher findByTno(String Tno){
        return teacherPrository.findByTno(Tno);
    }

    //增加信息
    public void insertOne(Teacher teacher){
        teacherPrository.save(teacher);
    }

    //删除信息
    public void deleteOne(String Tno){
        teacherPrository.deleteByTno(Tno);
    }

    //更新信息
    public void updateOne(Teacher teacher){
        teacherPrository.save(teacher);
    }

    //找出工号最大的教职工
    public Teacher findMaxTno(){
        return teacherPrository.findMaxTno();
    }
}
